import java.util.Scanner;

public class 有参数有返回值 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入整数n: ");
        int n = sc.nextInt();
        System.out.println(getFactorial(n));
    }

    public static int getFactorial(int n) {
        int sum = 1;
        if (n < 0) {
            System.out.println("负数没有阶乘！");
        } else if (n == 0 || n == 1) {
            System.out.println( n + "的阶乘为1");
        } else {
            for (int i = 1; i <= n; i++) {
                sum *= i;
            }
            return sum;
        }
        return sum;
    }
}